Alternative to "inheritance versus composition?" [closed]

Posted by Frank on Programmers See other posts from Programmers or by Frank
Published on 2012-11-12T16:59:31Z Indexed on 2012/11/12 23:13 UTC
Read the original article Hit count: 267

Possible Duplicate:
Where does this concept of “favor composition over inheritance” come from?

I have colleagues at work who claim that "Inheritance is an anti-pattern" and want to use composition systematically instead, except in (rare, according to them) cases where inheritance is really the best way to go.

I want to suggest an alternative where we continue using inheritance, but it is strictly forbidden (enforced by code reviews) to use anything but public members of base classes in derived classes.

For a case where we don't need to swap components of a class at runtime (static inheritance), would that be equivalent enough to composition? Or am I forgetting some other important aspect of composition?

© Programmers or respective owner

Related posts about design

Related posts about design-patterns